/* This is a generated file. Don't edit. Edit the source instead.
 */

#include <stdlib.h>
#include "cmd_table.h"
#include "sphashd_cmd.h"

static int hc_cmd_add(void *user_data, int argc, char **argv)
{
    hc_t *hc = user_data;
    if(hc == NULL) return 0;
    if(argc != 1) return 0;
    char *filename = argv[0];
    if(hc->cb_add)
        return hc->cb_add(hc, filename);
    return 0;
}

static int hc_cmd_shutdown(void *user_data, int argc, char **argv)
{
    hc_t *hc = user_data;
    if(hc == NULL) return 0;
    if(argc != 0) return 0;
    if(hc->cb_shutdown)
        return hc->cb_shutdown(hc);
    return 0;
}

static int hc_cmd_abort(void *user_data, int argc, char **argv)
{
    hc_t *hc = user_data;
    if(hc == NULL) return 0;
    if(argc != 0) return 0;
    if(hc->cb_abort)
        return hc->cb_abort(hc);
    return 0;
}

static int hc_cmd_set_delay(void *user_data, int argc, char **argv)
{
    hc_t *hc = user_data;
    if(hc == NULL) return 0;
    if(argc != 1) return 0;
    unsigned int delay = strtoull(argv[0], NULL, 0);
    if(hc->cb_set_delay)
        return hc->cb_set_delay(hc, delay);
    return 0;
}
static cmd_t hc_cmds[] = {
    {"set-delay", hc_cmd_set_delay, 1},
    {"add", hc_cmd_add, 1},
    {"abort", hc_cmd_abort, 0},
    {"shutdown", hc_cmd_shutdown, 0},
    {0, 0, -1}
};

hc_t *hc_init(void)
{
    hc_t *hc = calloc(1, sizeof(hc_t));
    return hc;
}

int hc_dispatch_command(const char *line, const char *delimiters,
        int allow_null_elements, hc_t *hc)
{
    return cmd_dispatch(line, delimiters, allow_null_elements,
        hc_cmds, hc);
}
